import json


class Student(object):
    """docstring for Student"""
    def __init__(self, name, age, score):
        super(Student, self).__init__()
        self.name = name
        self.age = age
        self.score = score


def objtodict(std):
    return {
        'name': std.name,
        'age': std.age,
        'score': std.score
    }


def objtodict1(obj):
    d = dict()
    for i in obj:
        dict[i] = obj[i]
    return d

s = Student('Bob', 20, 99)

print(json.dumps(s, default=lambda obj: obj.__dict__))
